package com.sky.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.sky.entity.DishFlavor;
import com.sky.mapper.DishFlavorMapper;
import com.sky.service.DishFlavorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 菜品业务层
 */
@Service
@Slf4j
public class DishFlavorServiceImpl implements DishFlavorService {

    @Autowired
    private DishFlavorMapper dishFlavorMapper;

    @Override
    public void inserBath(List<DishFlavor> flavors, Long id) {
        if (CollectionUtil.isNotEmpty(flavors)) {
            for (DishFlavor flavor : flavors) {
                flavor.setDishId(id);
                dishFlavorMapper.insert(flavor);
            }
        }
    }

    @Override
    public List<DishFlavor> selectByDishId(Long DishId) {
        if (null != DishId) {
           return dishFlavorMapper.selectByDishId(DishId);

        }
        return null;
    }
}
